﻿/*
=======================================================
    RegulatorUser【监管部门用户】
=======================================================
*/

namespace Services
{
    public interface IRegulatorUserLogic : ILogic<RegulatorUserModel, RegulatorUserFilterModel>
    {
        int UpdateIsDelete(bool flag, params int[] ids);
        void ResetPassword(List<int> ids, string pwd);
    }


    public class RegulatorUserLogic : BaseLogic<RegulatorUserModel, RegulatorUserFilterModel, RegulatorUser, IRegulatorUserRepository, IRegulatorUserMapping, IRegulatorUserService>, IRegulatorUserLogic
    {
        public RegulatorUserLogic(ICurrentUser currentUser, IRegulatorUserRepository repository, IRegulatorUserMapping mapping, IRegulatorUserService service)
            : base(currentUser, repository, mapping, service)
        {
        }

        #region 启用/禁用  UpdateIsDelete
        public int UpdateIsDelete(bool flag, params int[] ids)
        {
            return _repository.UpdateIsDelete(flag, ids);
        }
        #endregion

        #region Insert
        public override RegulatorUserModel Insert(RegulatorUserModel model)
        {
            if (_repository.GetLoginNameExists(model.LoginName, model.RegulatorID))
            {
                throw new CustomException("登录名已经存在！");
            }

            model.LoginPassword = Gx.DesEncrypt(model.LoginPassword);
            return base.Insert(model);
        }
        #endregion

        #region 重置密码  ResetPassword
        public void ResetPassword(List<int> ids, string pwd)
        {
            _repository.ResetPassword(ids, pwd);
        }
        #endregion
    }
}
